<style scoped>
  .weui-media-box_appmsg .weui-media-box__hd {
    font-size: 12px;
    /*background: #ccc;*/
    color: #fff;
  }
  .weui-media-box_appmsg .weui-media-box__hd .blue {
    background: #296BCC !important;
  }
  .weui-media-box__desc {
    font-size: 12px;
  }
  .weui-media-box__title {
    white-space: normal;
    font-size: 14px;
    margin-bottom: 5px;
      padding: 3px 0;
  }
  .weui-form-preview__bd {
    text-align: left;
  }

  .weui-form-preview {
    position: relative;
    background-color: #fff;
    margin: 1%;
    border-radius: 5px;
    min-width: 260px;
      border-bottom: 1px solid #eee;
  }
  .time {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 10px;
    color: #ccc;
  }

  .logimg {
    width: 14px;
    height: 14px;
  }
  .datalist {
    background: #e3e3e3;
    height: 100%;
    overflow: hidden;
  }
  .datalist.nodata {
    font-size: 14px;
    padding: 5px;
  }
  .tit {
    font-size: 12px;
    text-align: left;
    padding: 5px 15px 0 30px;
  }

  .weui-media-box_appmsg {
    display: block !important;
    font-size: 0;
      padding: 5px;
  }
  .weui-media-box_appmsg .weui-media-box__hd {
    margin-right: 3% !important;
    width: 23%;
    height: 23%;
    white-space: nowrap;
    /*line-height: 23%;*/
    display: inline-block !important;
  }
  .weui-media-box_appmsg .weui-media-box__bd {
    display: inline-block !important;
    width: 71%;
  }
  .weui-media-box__desc {
    overflow: initial;
    line-height: 1.4;
    display: flex;
  }
  .weui-media-box_appmsg .weui-media-box__hd .nodenm{
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 50%;
    background: #ccc;
    margin: 0 auto;
      text-align: center;
  }
  .weui-form-preview {

  }
  a:hover {
      cursor: auto;
  }
</style>
<template>
  <div class="logs">
    <!--    <div class="rj-wrap">-->
    <!--      审批记录-->
    <!--      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">-->
    <!--        <img src="../../assets/back.png" style="width: 20px" />-->
    <!--      </a>-->
    <!--    </div>-->
    <div style="overflow:auto;overflow-x: hidden;" v-show="nodes.length > 0" id="wrap">
      <div class="weui-form-preview" v-for="(item, index) in nodes">
        <div class="weui-form-preview__bd">
          <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
            <div class="weui-media-box__hd" style="overflow: hidden; float: left;">
              <div class="nodenm"  :class="item.status == 2 ? 'blue' : ''">{{item.name}}</div>
            </div>
            <div class="weui-media-box__bd" style="position: relative; float: left;">
              <p class="time">{{filterNull(item.logs).createtime}}</p>
              <h4 class="weui-media-box__title" v-if="item.operators.length <= 1" v-for="(oper, i) in item.operators">{{oper.realname}}</h4>
              <h4 class="weui-media-box__title" v-if="item.operators.length > 1"><span v-for="(oper2, i) in item.operators">{{oper2.realname}}<i v-show="i+1 != item.operators.length"> / </i></span></h4>
              <p class="weui-media-box__desc">{{filterNull(item.logs).description}}</p>
              <div class="exp uploaderFiles" style="display: inline-block;padding-top: 5px;" v-if="item.logs != null && item.logs.imgs.length > 0">
                  <viewer :images="item.logs.imgs">
                      <img class="logimg" style="padding-right: 5px;cursor: pointer;" v-for="(image, index) in item.logs.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/common/image/pic.png';this.onerror = null" :src="image.url + '.png'" >
                  </viewer>
              </div>
            </div>
              <div style="clear: both;"></div>
          </a>
        </div>
      </div>
    </div>
    <OperationLogs v-if="sellformpid != undefined" :orderid="sellformpid" :srguid="srguid" :departid="departid" :ordercode="sellformpcode"></OperationLogs>
    <div v-show="nodes.length <= 0 && sellformpid == undefined" class="datalist nodata" v-else>没有审批记录哦~</div>
  </div>
</template>

<script>
  import OperationLogs from '../common/OperationLogs'

  import 'viewerjs/dist/viewer.css'
  import Viewer from 'v-viewer'
  import Vue from 'vue'
  Vue.use(Viewer)

  export default {
    name: 'OperationLogs2',
    data () {
      return {
        nodes: [],
        // orderid: '',
        // srguid: '',
        // departid: '',
        // sellformpid: '',
        // sellformpcode: ''
      }
    },
    props: [
      'orderid',
      'srguid',
      'departid',
      'sellformpid',
      'sellformpcode',

    ],
    components: {
      OperationLogs
    },
    watch: {
      'orderid': function (val) {
        this.getOperatelogs();
      },
      'srguid': function (val) {
        this.getOperatelogs();
      },
      'departid': function (val) {
        this.getOperatelogs();
      },
    },
    methods: {
      getOperatelogs: function (id) {
        if (this.orderid == undefined || this.srguid == undefined || this.departid == undefined) return;
        this.axios({
          method: 'get',
          url: '/sales/Flowtempnode!getFlowNodes.action',
          params: {guid: this.orderid, srguid: this.srguid, departid: this.departid}
        }).then(response => {
          if (response.data.msg == 'success') {
            let data = response.data;
            this.$nextTick(function () {
              this.nodes = data.nodes;
            })
          } else {
            //this.toastText('获取审批记录失败');
          }
        });
      },
      filterNull: function (obj) {
        return obj != null ? obj : {};
      },
      openLogs: function() {
        this.$router.push({name: 'OperationLogs2', query: {orderid: this.id, srguid: this.sellform.storermguid, departid: this.sellform.depguid}});
      }
    }
  }
</script>
